<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<script src="https://cdn.jsdelivr.net/npm/clipboard@2/dist/clipboard.min.js"></script>
<script>
    var clipboard = new ClipboardJS('.btn');
    clipboard.on('success', function(e) {
        alert("复制成功！");
    });
    clipboard.on('error', function(e) {
        alert("复制失败！");
    });
</script>
<div id="shareTab" style="visibility:visible; display: none;">
  <!-- Nav tabs -->
  <ul class="nav nav-tabs" role="tablist">
    <li role="presentation" class="active"><a aria-controls="home" role="tab" data-toggle="tab">显示所有分享</a></li>
  </ul>

  <!-- Tab panes -->
	<div class="row">
		<div class="col-sm-9 col-sm-offset-3 col-md-10 col-lg-10 col-md-offset-1 main" id="main" style="margin-left: 10px;width: 880px;">
			<div class="table-responsive">
				<table class="table table-striped table-hover">
					<thead >
					<tr >
						<th style="width: 116px;"><span class="glyphicon glyphicon-user"></span> <span >文件名</span></th>
						<th colspan="1" width="50%"><span class="glyphicon glyphicon-bookmark" ></span> <span >分享链接</span></th>
						<th style="width: 150px"><span class="glyphicon glyphicon-pushpin"  style="width: 20px"></span> <span>文件大小</span></th>
						<th style="width: 116px;"><span class="glyphicon glyphicon-time" style="width: 20px"></span> <span >分享时间</span></th>
						<th style="width: 75px"><span class="glyphicon glyphicon-pencil"></span> <span >操作</span></th>
					</tr>
					</thead>
					<tbody id="tbody-share">

					</tbody>

				</table>
			</div>
		</div>
	</div>
	</section>
</div>

<script src="/js/jquery-1-4-2.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<!--script src="js/admin-scripts.js"></script-->
<script type="text/javascript">

    //获取所有标签
    function myshare() {
        $.ajax({
            url: "../shares/selectAllShares",
            type: "POST",
            dataType: 'json',
            data: {},
            success: function (data) {
                <!-- 处理后端返回的数据 -->
                var str = "";
                var tbody = window.document.getElementById("tbody-share");
                for (i in data) {
                    var id="id"+data[i].shareId.split(".")[0];
                    str += "<tr id='" + data[i].shareId + "'>" +
                        "<td>" + data[i].files.fileName + "</td>" +
                        "<td><input id='" + id + "'type=\"text\" value=\""+data[i].shareUrl+"\" style='width: 250px' readonly></td>" +
                        "<td>" + data[i].files.fileFullSize + "</td>";
                    str+="<td>" +data[i].shareTime+ "</td>"+
                        "<td><button class=\"btn\"  data-clipboard-action=\"copy\" data-clipboard-target=\"#"+id+"\">复制链接</button><button style='background: none;border: none' onclick='delete_shares(\""+data[i].shareId+"\")'>取消分享</button></td>";
                    str += "</td></tr>";
                }
                tbody.innerHTML = str;
            },
            error: function (data) {
                alert("刷新失败")
            }
        })
    }
    //是否确认删除
    function delete_shares(shareId){
        if(window.confirm("是否确认取消分享？")){
            $.ajax({
                type: "POST",
                url: "../shares/delete",
                data: {"shareId": shareId },
                cache: false, //不缓存此页面
                success: function (data) {
                    if(data=="success"){
                        var t=document.getElementById(shareId);
                        //alert(t==null);
                        t.style.display="none";
                    }else{
                        alert("操作失败");
                    }
                },
                error:function () {
                    alert("error")
                }
            });
        }
    }

    $(document).ready(function(e) {
        myshare();
    });
</script>


<div id="fileTypeList" style="visibility:visible; display: none;">
  <!-- Nav tabs -->
 <ul class="nav navbar-fixed-top nav-tabs"  role="tablist" style="background: white; margin-bottom: 40px; z-index: 0">
   <li role="presentation" class="active"><a href="#imageTab" onclick="return changeTypeTab('image')" aria-controls="imageTab" role="tab" data-toggle="tab">图片</a></li>
   <li role="presentation"><a href="#officeTab" onclick="return changeTypeTab('office')" aria-controls="officeTab" role="tab" data-toggle="tab">文档</a></li>
   <li role="presentation"><a href="#vidoTab" onclick="return changeTypeTab('vido')" aria-controls="vidoTab" role="tab" data-toggle="tab">视频</a></li>
   <li role="presentation"><a href="#audioTab" onclick="return changeTypeTab('audio')" aria-controls="audioTab" role="tab" data-toggle="tab">音乐</a></li>
   <li role="presentation"><a href="#documTab" onclick="return changeTypeTab('docum')" aria-controls="documTab" role="tab" data-toggle="tab">文件夹</a></li>
   <li role="presentation"><a href="#fileTab" onclick="return changeTypeTab('file')" aria-controls="fileTab" role="tab" data-toggle="tab">其他</a></li>
 </ul>


  <!-- Tab panes -->
  <div class="tab-content" style="margin-top: 42px;margin-left: 40px;margin-right: 30px;">
	  <!--图片-->
    <div role="tabpanel" class="tab-pane active" id="imageTab">
		<div class="panel panel-default">
			<table class="table table-hover">
				<thead>
				<tr>
					<th><span class="glyphicon glyphicon-user"></span> <span >图片名称</span></th>
					<th><span class="glyphicon glyphicon-text-size"></span> <span >图片大小</span></th>
					<th><span class="glyphicon glyphicon-time"></span> <span >分享时间</span></th>
					<th><span class="glyphicon glyphicon-pencil"></span> <span >操作</span></th>
				</tr>
				</thead>
				<tbody id="tbody-picture">

				</tbody>
			</table>
		</div>
	</div>

	  <!--文档-->
    <div role="tabpanel" class="tab-pane" id="officeTab">
	  <div class="panel panel-default">
	  	<table class="table table-hover">
   		<thead>
   			<tr>
				<th><span class="glyphicon glyphicon-user"></span> <span >文档名称</span></th>
				<th><span class="glyphicon glyphicon-text-size"></span> <span >文本大小</span></th>
				<th><span class="glyphicon glyphicon-time"></span> <span >分享时间</span></th>
				<th><span class="glyphicon glyphicon-pencil"></span> <span >操作</span></th>
   			</tr>
   		</thead>
   		<tbody id="tbody-result">

   		</tbody>
   		</table>
		</div>
    </div>

      <!--视频-->
    <div role="tabpanel" class="tab-pane" id="vidoTab">
    	<div class="panel panel-default">
	  	<table class="table table-hover">
   		<thead>
   			<tr>
				<th><span class="glyphicon glyphicon-user"></span> <span >视频名称</span></th>
				<th><span class="glyphicon glyphicon-text-size"></span> <span >视频大小</span></th>
				<th><span class="glyphicon glyphicon-time"></span> <span >分享时间</span></th>
				<th><span class="glyphicon glyphicon-pencil"></span> <span >操作</span></th>
   			</tr>
   		</thead>
   		<tbody id="tbody-video">

   		</tbody>
   		</table>
		</div>
    </div>

	  <!--音乐-->
    <div role="tabpanel" class="tab-pane" id="audioTab">
    	<div class="panel panel-default">
	  	<table class="table table-hover">
   		<thead>
   			<tr>
				<th><span class="glyphicon glyphicon-user"></span> <span >音乐名称</span></th>
				<th><span class="glyphicon glyphicon-text-size"></span> <span >音乐大小</span></th>
				<th><span class="glyphicon glyphicon-time"></span> <span >分享时间</span></th>
				<th><span class="glyphicon glyphicon-pencil"></span> <span >操作</span></th>
   			</tr>
   		</thead>
   		<tbody id="tbody-music">

   		</tbody>
   		</table>
		</div>
    </div>

	  <!--文本-->
    <div role="tabpanel" class="tab-pane" id="documTab">
    	<div class="panel panel-default">
	  	<table class="table table-hover">
   		<thead>
   			<tr>
				<th><span class="glyphicon glyphicon-user"></span> <span >文本名称</span></th>
				<th><span class="glyphicon glyphicon-text-size"></span> <span >文本大小</span></th>
				<th><span class="glyphicon glyphicon-time"></span> <span >分享时间</span></th>
				<th><span class="glyphicon glyphicon-pencil"></span> <span >操作</span></th>
   			</tr>
   		</thead>
   		<tbody id="tbody-text">

   		</tbody>
   		</table>
		</div>
    </div>

	  <!--其他-->
    <div role="tabpanel" class="tab-pane" id="fileTab">
    	<div class="panel panel-default">
	  	<table class="table table-hover">
   		<thead>
   			<tr>
				<th><span class="glyphicon glyphicon-user"></span> <span >文件名称</span></th>
				<th><span class="glyphicon glyphicon-text-size"></span> <span >文件大小</span></th>
				<th><span class="glyphicon glyphicon-time"></span> <span >时间</span></th>
				<th><span class="glyphicon glyphicon-pencil"></span> <span >操作</span></th>
   			</tr>
   		</thead>
   		<tbody id="tbody-other">

   		</tbody>
   		</table>
		</div>
    </div>
  </div>

	<!--获取，删除图片-->
	<script type="text/javascript">
        //获取所有标签
        function picture() {
            $.ajax({
                url: "../files/findFilesByType",
                type: "POST",
                dataType: 'json',
                data: {"fileType":4},
                success: function (data) {
                    <!-- 处理后端返回的数据 -->
                    var str = "";
                    var tbody = window.document.getElementById("tbody-picture");
                    for (i in data) {
                        str += "<tr id='" + data[i].fileId + "'>" +
                            "<td>"+"<img src=\"../img/yyc-images/filetype/png.png\" width=\"9%\">" + data[i].fileName + "</td>" +
                            "<td>" + data[i].fileFullSize + "</td>";
                        str+="<td>" +data[i].stringTime+ "</td>"+
                            "<td><a onclick='delete_picture(\""+data[i].fileId+"\")'>&emsp;删除图片</a></td>";
                        str += "</td></tr>";
                    }
                    tbody.innerHTML = str;
                },
                error: function (data) {
                    alert("刷新失败")
                }
            })
        }
        //确认删除文档
        function delete_picture(fileId){
            if(window.confirm("是否确认删除图片？")){
                $.ajax({
                    type: "POST",
                    url: "../files/deleteTab",
                    data: {"id": fileId },
                    cache: false, //不缓存此页面
                    success: function (data) {
                        if(data=="success"){
                            var t=document.getElementById(fileId);
                            t.style.display="none";
                        }else{
                            alert("删除失败");
                        }
                    },
                    error:function () {
                        alert("删除error")
                    }
                });
            }
        }

        $(document).ready(function(e) {
            picture();
        });
	</script>

	<!--获取，删除文档-->
	<script type="text/javascript">
        //获取所有标签
        function load() {
            $.ajax({
                url: "../files/findFilesByType",
                type: "POST",
                dataType: 'json',
                data: {"fileType":2},
                success: function (data) {
                    <!-- 处理后端返回的数据 -->
                    var str = "";
                    var tbody = window.document.getElementById("tbody-result");
                    for (i in data) {
                        str += "<tr id='" + data[i].fileId + "'>" +
                            "<td>"+"<img src=\"../img/yyc-images/filetype/text.png\" width=\"8%\">" + data[i].fileName + "</td>" +
                            "<td>" + data[i].fileFullSize + "</td>";
                        str+="<td>" +data[i].stringTime + "</td>"+
                            "<td><a onclick='delete_document(\""+data[i].fileId+"\")'>&emsp;删除文档</a></td>";
                        str += "</td></tr>";
                    }
                    tbody.innerHTML = str;
                },
                error: function (data) {
                    alert("刷新失败")
                }
            })
        }
        //确认删除文档
        function delete_document(fileId){
            if(window.confirm("是否确认删除文档？")){
                $.ajax({
                    type: "POST",
                    url: "../files/deleteTab",
                    data: {"id": fileId },
                    cache: false, //不缓存此页面
                    success: function (data) {
                        if(data=="success"){
                            var t=document.getElementById(fileId);
                            //alert(t==null);
                            t.style.display="none";
                        }else{
                            alert("删除失败");
                        }
                    },
                    error:function () {
                        alert("删除error")
                    }
                });
            }
        }

        $(document).ready(function(e) {
            load();
        });
	</script>

	<!--获取，删除视频-->
	<script type="text/javascript">
        //获取所有标签
        function video() {
            $.ajax({
                url: "../files/findFilesByType",
                type: "POST",
                dataType: 'json',
                data: {"fileType":1},
                success: function (data) {
                    <!-- 处理后端返回的数据 -->
                    var str = "";
                    var tbody = window.document.getElementById("tbody-video");
                    for (i in data) {
                        str += "<tr id='" + data[i].fileId + "'>" +
                            "<td>"+"<img src=\"../img/yyc-images/filetype/mp4.png\" width=\"8%\">" + data[i].fileName + "</td>" +
                            "<td>" + data[i].fileFullSize + "</td>";
                        str+="<td>" +data[i].stringTime+ "</td>"+
                            "<td><a onclick='delete_video(\""+data[i].fileId+"\")'>&emsp;删除视频</a></td>";
                        str += "</td></tr>";
                    }
                    tbody.innerHTML = str;
                },
                error: function (data) {
                    alert("刷新失败")
                }
            })
        }
        //确认删除视频
        function delete_video(fileId){
            if(window.confirm("是否确认删除视频？")){
                $.ajax({
                    type: "POST",
                    url: "../files/deleteTab",
                    data: {"id": fileId },
                    cache: false, //不缓存此页面
                    success: function (data) {
                        if(data=="success"){
                            var t=document.getElementById(fileId);
                            //alert(t==null);
                            t.style.display="none";
                        }else{
                            alert("删除失败");
                        }
                    },
                    error:function () {
                        alert("删除error")
                    }
                });
            }
        }

        $(document).ready(function(e) {
            video();
        });
	</script>

	<!--获取，删除音乐-->
	<script type="text/javascript">
        //获取所有音乐
        function music() {
            $.ajax({
                url: "../files/findFilesByType",
                type: "POST",
                dataType: 'json',
                data: {"fileType":3},
                success: function (data) {
                    <!-- 处理后端返回的数据 -->
                    var str = "";
                    var tbody = window.document.getElementById("tbody-music");
                    for (i in data) {
                        str += "<tr id='" + data[i].fileId + "'>" +
                            "<td>"+"<img src=\"../img/yyc-images/filetype/mp3.png\" width=\"8%\">" + data[i].fileName + "</td>" +
                            "<td>" + data[i].fileFullSize + "</td>";
                        str+="<td>" +data[i].stringTime+ "</td>"+
                            "<td><a onclick='delete_music(\""+data[i].fileId+"\")'>&emsp;删除音乐</a></td>";
                        str += "</td></tr>";
                    }
                    tbody.innerHTML = str;
                },
                error: function (data) {
                    alert("刷新失败")
                }
            })
        }
        //确认删除该音乐
        function delete_music(fileId){
            if(window.confirm("是否确认删除该音乐？")){
                $.ajax({
                    type: "POST",
                    url: "../files/deleteTab",
                    data: {"id": fileId },
                    cache: false, //不缓存此页面
                    success: function (data) {
                        if(data=="success"){
                            var t=document.getElementById(fileId);
                            t.style.display="none";
                        }else{
                            alert("删除失败");
                        }
                    },
                    error:function () {
                        alert("删除error")
                    }
                });
            }
        }

        $(document).ready(function(e) {
            music();
        });
	</script>

	<!--获取，删除文本-->
	<script type="text/javascript">
        //获取所有标签
        function text() {
            $.ajax({
                url: "../files/findFilesByType",
                type: "POST",
                dataType: 'json',
                data: {"fileType":5},
                success: function (data) {
                    <!-- 处理后端返回的数据 -->
                    var str = "";
                    var tbody = window.document.getElementById("tbody-text");
                    for (i in data) {
                        str += "<tr id='" + data[i].fileId + "'>" +
                            "<td>"+"<img src=\"../img/yyc-images/filetype/icon.png\" width=\"7%\">" + data[i].fileName + "</td>" +
                            "<td>" + data[i].fileFullSize + "</td>";
                        str+="<td>" +data[i].stringTime+ "</td>"+
                            "<td><a onclick='delete_text(\""+data[i].fileId+"\")'>&emsp;删除文本</a></td>";
                        str += "</td></tr>";
                    }
                    tbody.innerHTML = str;
                },
                error: function (data) {
                    alert("刷新失败")
                }
            })
        }
        //确认删除文本
        function delete_text(fileId){
            if(window.confirm("是否确认删除文本？")){
                $.ajax({
                    type: "POST",
                    url: "../files/deleteTab",
                    data: {"id": fileId },
                    cache: false, //不缓存此页面
                    success: function (data) {
                        if(data=="success"){
                            var t=document.getElementById(fileId);
                            t.style.display="none";
                        }else{
                            alert("删除失败");
                        }
                    },
                    error:function () {
                        alert("删除error")
                    }
                });
            }
        }

        $(document).ready(function(e) {
            text();
        });
	</script>

	<!--获取，删除其他文件-->
	<script type="text/javascript">
        //获取所有标签
        function other() {
            $.ajax({
                url: "../files/findFilesByType",
                type: "POST",
                dataType: 'json',
                data: {"fileType":6},
                success: function (data) {
                    <!-- 处理后端返回的数据 -->
                    var str = "";
                    var tbody = window.document.getElementById("tbody-other");
                    for (i in data) {
                        str += "<tr id='" + data[i].fileId + "'>" +
                            "<td>"+"<img src=\"../img/yyc-images/filetype/other.png\" width=\"8%\">" + data[i].fileName + "</td>" +
                            "<td>" + data[i].fileFullSize + "</td>";
                        str+="<td>" +data[i].stringTime+ "</td>"+
                            "<td><a onclick='delete_other(\""+data[i].fileId+"\")'>&emsp;删除文件</a></td>";
                        str += "</td></tr>";
                    }
                    tbody.innerHTML = str;
                },
                error: function (data) {
                    alert("刷新失败")
                }
            })
        }
        //确认删除文档
        function delete_other(fileId){
            if(window.confirm("是否确认删除文件？")){
                $.ajax({
                    type: "POST",
                    url: "../files/deleteTab",
                    data: {"id": fileId },
                    cache: false, //不缓存此页面
                    success: function (data) {
                        if(data=="success"){
                            var t=document.getElementById(fileId);
                            t.style.display="none";
                        }else{
                            alert("删除失败");
                        }
                    },
                    error:function () {
                        alert("删除error")
                    }
                });
            }
        }

        $(document).ready(function(e) {
            other();
        });
	</script>

</div>

